<?php
// system/application/models/user.php
class User extends CI_Model{
	
	public function __construct(){
	  parent::__construct();
	}
	
	public function get_roles() {
		$ret = $this->db->select()->from('role')->get()->result();
		return $ret;
	}
	
	public function get_role($role_id) {
		$ret = $this->db->select()->from('role')->where('id', $role_id)->get()->row_object();
		return $ret;
	}
	
	public function get_users() {
		$ret = $this->db->select()->from('user')->get()->result();
		//$sql = "select user_id,account,user.name,phone,sex,insert_time,role.name as role_id from user join role where user.role_id = role.id";
		//$ret = $this->db->query($sql)->result();
		return $ret;
	}
	
	public function get_user($user_id){
		$ret = $this->db->select()->from('user')->where('user_id', $user_id)->get()->row_object();
		return $ret;
	}
}
